import 'package:core_package/ui/widget/my_asset_image.dart';
import 'package:flutter/material.dart';
import 'package:core_package/core_package.dart';

class SelectPayTypeWidget extends StatelessWidget {
  final Function()? weChatPayOnTop;
  final Function()? alipayPayOnTop;
  final List<String> icons;
  final String title;

  const SelectPayTypeWidget({
    Key? key,
    this.weChatPayOnTop,
    this.alipayPayOnTop,
    this.icons = const ["icon_we_chat_pay", "icon_alipy_pay"],
    this.title = "选择支付方式",
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          MySizeBox(height: 10.px),
          Row(
            children: [
              Expanded(child: SizedBox()),
              GestureDetector(
                behavior: HitTestBehavior.opaque,
                onTap: () {
                  Navigator.pop(context);
                },
                child: MyAssetImage(
                  "icon_close",
                  width: 20.px,
                  height: 20.px,
                ),
              ),
              MySizeBox(width: 10.px),
            ],
          ),
          Padding(
            padding: EdgeInsets.only(left: 40.px, top: 20.px),
            child: Text(
              title,
              style: TextStyle(
                color: MyColors.formHex("#272727FF"),
                fontSize: MyFont.font13,
                fontWeight: MyFontWeight.regular,
              ),
            ),
          ),
          MySizeBox(height: 25.px),
          Row(
            children: [
              MySizeBox(width: 40.px),
              GestureDetector(
                onTap: () {
                  NavigatorUtil.pop(context);

                  if (weChatPayOnTop != null) {
                    weChatPayOnTop?.call();
                  }
                },
                child: MyAssetImage(
                  icons[0],
                  width: 41.px,
                  height: 41.px,
                ),
              ),
              MySizeBox(width: 40.px),
              if(icons.length>1)
              GestureDetector(
                onTap: () {
                  NavigatorUtil.pop(context);

                  if (alipayPayOnTop != null) {
                    alipayPayOnTop?.call();
                  }
                },
                child: MyAssetImage(
                  icons[1],
                  width: 41.px,
                  height: 41.px,
                ),
              ),
            ],
          )
        ],
      ),
    );
  }
}
